package Entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Ferrari
 */
@Entity
@Table(name = "hd_tipo_user")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "HdTipoUser.findAll", query = "SELECT h FROM HdTipoUser h"),
    @NamedQuery(name = "HdTipoUser.findByCoTipoUser", query = "SELECT h FROM HdTipoUser h WHERE h.coTipoUser = :coTipoUser"),
    @NamedQuery(name = "HdTipoUser.findByStAdmin", query = "SELECT h FROM HdTipoUser h WHERE h.stAdmin = :stAdmin"),
    @NamedQuery(name = "HdTipoUser.findByDeTipoUser", query = "SELECT h FROM HdTipoUser h WHERE h.deTipoUser = :deTipoUser")})
public class HdTipoUser implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "co_tipo_user")
    private Integer coTipoUser;
    @Basic(optional = false)
    @Column(name = "de_tipo_user")
    private String deTipoUser;
    @Basic(optional = false)
    @Column(name = "st_admin")
    private boolean stAdmin;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "coTipoUser")
    private List<HdUsers> hdUsersList;

    public HdTipoUser() {
    }

    public HdTipoUser(Integer coTipoUser) {
        this.coTipoUser = coTipoUser;
    }

    public HdTipoUser(Integer coTipoUser, String deTipoUser) {
        this.coTipoUser = coTipoUser;
        this.deTipoUser = deTipoUser;
    }

    public Integer getCoTipoUser() {
        return coTipoUser;
    }

    public void setCoTipoUser(Integer coTipoUser) {
        this.coTipoUser = coTipoUser;
    }

    public String getDeTipoUser() {
        return deTipoUser;
    }

    public void setDeTipoUser(String deTipoUser) {
        this.deTipoUser = deTipoUser;
    }

    @XmlTransient
    public List<HdUsers> getHdUsersList() {
        return hdUsersList;
    }

    public void setHdUsersList(List<HdUsers> hdUsersList) {
        this.hdUsersList = hdUsersList;
    }

    public boolean getStAdmin() {
        return stAdmin;
    }

    public void setStAdmin(boolean stAdmin) {
        this.stAdmin = stAdmin;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (coTipoUser != null ? coTipoUser.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof HdTipoUser)) {
            return false;
        }
        HdTipoUser other = (HdTipoUser) object;
        if ((this.coTipoUser == null && other.coTipoUser != null) || (this.coTipoUser != null && !this.coTipoUser.equals(other.coTipoUser))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entities.HdTipoUser[ coTipoUser=" + coTipoUser + " ]";
    }
    
    public boolean isAdmin(){
        return stAdmin;
    }
    
}
